package com.ruoyi.framework.flex;

import com.mybatisflex.annotation.InsertListener;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.SecurityUtils;

public class CreateByListener implements InsertListener {

    @Override
    public void onInsert(Object entity) {
        BaseEntity baseEntity = (BaseEntity) entity;
        try {
            baseEntity.setCreateBy(SecurityUtils.getUsername());
        } catch (Exception e) {
            baseEntity.setCreateBy("系统管理员");
        }
    }
}
